package com.quasar.hpatient.presenter;

import android.graphics.Bitmap;

import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnPhotoListener;
import com.quasar.hpatient.onInterface.viewInterface.UiInterface;
import com.vise.log.ViseLog;

/**
 * author : 许建宏
 * Date: 2017/11/21 0021
 * View:下载图片
 */

public class ImagePresenter {


    private RequestModel requestModel;
    private OnPhotoListener onPhotoListener;

    public ImagePresenter(OnPhotoListener onPhotoListener) {
        this.requestModel = new RequestModel();
        this.onPhotoListener = onPhotoListener;
    }


    public void GetImageUrls(String Imageurl) {

        requestModel.DownImage(Imageurl, new AnotherResultListener<Bitmap>() {
            @Override
            public void onSuccess(Bitmap data) {
                onPhotoListener.onViewSuccess(data);
            }

            @Override
            public void onError(String msg) {
                ViseLog.d("ImagePresenter"+msg);
                onPhotoListener.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                onPhotoListener.onViewRefreshUI();
            }
        });
    }

    //删除
    public void deletePhoto(String id){

        requestModel.DeleteInspectionPicData(id, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onPhotoListener.onDeletePtoto(data);
            }

            @Override
            public void onError(String msg) {
                onPhotoListener.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                onPhotoListener.onViewRefreshUI();
            }
        });
    }


}
